

const assetResources = {
  img: {
    waterGrass: [
      {
        url: 'grass_00000.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00001.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00002.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00003.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00004.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00005.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00006.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00007.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00008.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00009.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00010.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00011.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00012.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00013.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00014.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00015.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00016.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00017.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00018.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00019.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00020.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00021.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00022.png',
        crossOrigin: true,
      },
      {
        url: 'grass_00023.png',
        crossOrigin: true,
      },
    ],
    loading: [
      {
        url: 'beginBtn.png',
        crossOrigin: true,
      },
      // {
      //   url: 'rule.png',
      //   crossOrigin: true,
      // },
      {
        url: 'ruleBg.png',
        crossOrigin: true,
      },
      {
        url: 'ruleClose.png',
        crossOrigin: true,
      },
    ],
    background: [
      {
        url: 'handSlide.png',
        crossOrigin: true,
      },
      {
        url: 'background.jpg',
        crossOrigin: true,
      },
      {
        url: 'sunshine.png',
        crossOrigin: true,
      },
      {
        url: 'gold.png',
        crossOrigin: true,
      },
    ],
    game: [
      {
        url: 'click.png',
        crossOrigin: true,
      },
      {
        url: 'unOpenPromptBg.png',
        crossOrigin: true,
      },
      {
        url: 'modalContent.png',
        crossOrigin: true,
      },
      {
        url: 'modalSmallContent.png',
        crossOrigin: true,
      },
      {
        url: 'slider.png',
        crossOrigin: true,
      },
      {
        url: 'sliderBtn.png',
        crossOrigin: true,
      },
      {
        url: 'stick.png',
        crossOrigin: true,
      },
      {
        url: 'shake.png',
        crossOrigin: true,
      },
      {
        url: 'push.png',
        crossOrigin: true,
      },
      {
        url: 'submit.png',
        crossOrigin: true,
      },
    ],
    items: [
      {
        url: 'itemBg.png',
        crossOrigin: true,
      },
      {
        url: 'itemSelectBg.png',
        crossOrigin: true,
      },
      {
        url: 'needle.png',
        crossOrigin: true,
      },
      {
        url: 'amethyst.png',
        crossOrigin: true,
      },
      {
        url: 'glass.png',
        crossOrigin: true,
      },
      {
        url: 'ink.png',
        crossOrigin: true,
      },
      {
        url: 'poster.png',
        crossOrigin: true,
      },
      {
        url: 'poster2.png',
        crossOrigin: true,
      },
      {
        url: 'sunBlock.png',
        crossOrigin: true,
      },
      {
        url: 'amethystBox.png',
        crossOrigin: true,
      },
    ],
    boxes: [
      {
        url: 'wanted.png',
        crossOrigin: true,
      },
      {
        url: 'book.png',
        crossOrigin: true,
      },
      {
        url: 'dendrobium.png',
        crossOrigin: true,
      },
      {
        url: 'redCoral.png',
        crossOrigin: true,
      },
      {
        url: 'fish.png',
        crossOrigin: true,
      },
      {
        url: 'stickBox.png',
        crossOrigin: true,
      },
      {
        url: 'woodenBox1.png',
        crossOrigin: true,
      },
      {
        url: 'woodenBox2.png',
        crossOrigin: true,
      },
      {
        url: 'woodenBoxOpen.png',
        crossOrigin: true,
      },
      {
        url: 'octopus.png',
        crossOrigin: true,
      },
      {
        url: 'ghost.png',
        crossOrigin: true,
      },
      {
        url: 'chest1.png',
        crossOrigin: true,
      },
      {
        url: 'chest2.png',
        crossOrigin: true,
      },
      {
        url: 'chestOpen.png',
        crossOrigin: true,
      },
      {
        url: 'door.jpg',
        crossOrigin: true,
      },
    ],
    award: [
      {
        url: 'beachBg.jpg',
        crossOrigin: true,
      },
      {
        url: 'beachBgPeople.png',
        crossOrigin: true,
      },
      {
        url: 'beachBgTitle.png',
        crossOrigin: true,
      },
      {
        url: 'copy.png',
        crossOrigin: true,
      },
      {
        url: 'awardBtn.png',
        crossOrigin: true,
      },
      {
        url: 'awardBg.png',
        crossOrigin: true,
      },
      {
        url: 'playAgain.png',
        crossOrigin: true,
      },
      {
        url: 'share.png',
        crossOrigin: true,
      },
      {
        url: 'cue.png',
        crossOrigin: true,
      },
      {
        url: 'award_small_1.png',
        crossOrigin: true,
      },
      {
        url: 'award_small_2.png',
        crossOrigin: true,
      },
      {
        url: 'award_small_3.png',
        crossOrigin: true,
      },
      {
        url: 'award_small_4.png',
        crossOrigin: true,
      },
      {
        url: 'award_small_5.png',
        crossOrigin: true,
      },
      {
        url: 'award_small_6.png',
        crossOrigin: true,
      },
      {
        url: 'award_1.png',
        crossOrigin: true,
      },
      {
        url: 'award_2.png',
        crossOrigin: true,
      },
      {
        url: 'award_3.png',
        crossOrigin: true,
      },
      {
        url: 'award_4.png',
        crossOrigin: true,
      },
      {
        url: 'award_5.png',
        crossOrigin: true,
      },
      {
        url: 'award_6.png',
        crossOrigin: true,
      },
      {
        url: 'close.png',
        crossOrigin: true,
      },
      {
        url: 'ok.png',
        crossOrigin: true,
      },
    ],
  }
};

export const addRes = async (type) => {
  let resources = [];

  for (let key in assetResources[type]) {

    let value = assetResources[type][key];

    value.forEach(item => {
      item.url = `${type}/${key}/${item.url}`;
      resources.push(item);
    });

  }

  await Promise.all(resources.map(item => {
    return new Promise((resolve) => {
      import(`common/asset/${item.url}`).then(res => {
        item.url = res;
        resolve(item);
      });
    });
  })).then(res => {
    resources = res;
  });

  return resources;
};

export default assetResources;
